interface DateConstant {
  ONE_DAY: number;
  ONE_HOUR: number;
  ONE_MINUTE: number;
  ONE_SECOND: number;
  TODAY: number;
  TOMORROW: number;
  YESTERDAY: number;
  THIS_WEEK: number;
  NEXT_WEEK: number;
  LAST_WEEK: number;
  THIS_MONTH: number;
  NEXT_MONTH: number;
  LAST_MONTH: number;
  LAST_3_DAYS: number[];
  LAST_7_DAYS: number[];
  LAST_30_DAYS: number[];
  LAST_1_YEAR: number[];
}

/**
 * @constant 日期常量
 * @author LinHan
 */
export const DATA_CONSTANT: DateConstant = {
  /**
   * 一天的毫秒数
   */
  ONE_DAY: 24 * 60 * 60 * 1000,

  /**
   * 一小时的毫秒数
   */
  ONE_HOUR: 60 * 60 * 1000,

  /**
   * 一分钟的毫秒数
   */
  ONE_MINUTE: 60 * 1000,

  /**
   * 一秒的毫秒数
   */
  ONE_SECOND: 1000,
  /**
   * 今天00:00:00的时间戳
   */
  TODAY: (() => {
    const today = new Date();
    today.setHours(0, 0, 0, 0);
    return today.getTime();
  })(),

  /**
   * 明天00:00:00的时间戳
   */
  TOMORROW: (() => {
    const tomorrow = new Date();
    tomorrow.setDate(tomorrow.getDate() + 1);
    tomorrow.setHours(0, 0, 0, 0);
    return tomorrow.getTime();
  })(),

  /**
   * 昨天00:00:00的时间戳
   */
  YESTERDAY: (() => {
    const yesterday = new Date();
    yesterday.setDate(yesterday.getDate() - 1);
    yesterday.setHours(0, 0, 0, 0);
    return yesterday.getTime();
  })(),

  /**
   * 本周的第一天（周一00:00:00）的时间戳
   */
  THIS_WEEK: (() => {
    const today = new Date();
    const day = today.getDay() || 7;
    const startOfWeek = new Date(today);
    startOfWeek.setDate(today.getDate() - day + 1);
    startOfWeek.setHours(0, 0, 0, 0);
    return startOfWeek.getTime();
  })(),

  /**
   * 下周的第一天（周一00:00:00）的时间戳
   */
  NEXT_WEEK: (() => {
    const today = new Date();
    const day = today.getDay() || 7;
    const startOfNextWeek = new Date(today);
    startOfNextWeek.setDate(today.getDate() + (7 - day + 1));
    startOfNextWeek.setHours(0, 0, 0, 0);
    return startOfNextWeek.getTime();
  })(),

  /**
   * 上周的第一天（周一00:00:00）的时间戳
   */
  LAST_WEEK: (() => {
    const today = new Date();
    const day = today.getDay() || 8;
    const endOfLastWeek = new Date(today);
    endOfLastWeek.setDate(today.getDate() - day + 1);
    endOfLastWeek.setHours(23, 59, 59, 999);
    return endOfLastWeek.getTime();
  })(),

  /**
   * 本月的第一天（00:00:00）的时间戳
   */
  THIS_MONTH: (() => {
    const today = new Date();
    const startOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
    startOfMonth.setHours(0, 0, 0, 0);
    return startOfMonth.getTime();
  })(),

  /**
   * 下月的第一天（00:00:00）的时间戳
   */
  NEXT_MONTH: (() => {
    const today = new Date();
    const startOfNextMonth = new Date(today.getFullYear(), today.getMonth() + 1, 1);
    startOfNextMonth.setHours(0, 0, 0, 0);
    return startOfNextMonth.getTime();
  })(),

  /**
   * 上月的最后一天（23:59:59）的时间戳
   */
  LAST_MONTH: (() => {
    const today = new Date();
    const lastDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 0);
    lastDayOfMonth.setHours(23, 59, 59, 999);
    return lastDayOfMonth.getTime();
  })(),

  /**
   * 近3天
   * @returns {number[]} 近3天的起止日期时间戳数组
   */
  LAST_3_DAYS: (() => {
    const today = new Date();
    today.setHours(0, 0, 0, 0);
    const threeDaysAgo = new Date(today);
    threeDaysAgo.setDate(today.getDate() - 3);
    return [threeDaysAgo.getTime(), today.getTime()];
  })(),

  /**
   * 近7天
   * @returns {number[]} 近7天的起止日期时间戳数组
   */
  LAST_7_DAYS: (() => {
    const today = new Date();
    today.setHours(0, 0, 0, 0);
    const sevenDaysAgo = new Date(today);
    sevenDaysAgo.setDate(today.getDate() - 7);
    return [sevenDaysAgo.getTime(), today.getTime()];
  })(),

  /**
   * 近30天
   * @returns {number[]} 近30天的起止日期时间戳数组
   */
  LAST_30_DAYS: (() => {
    const today = new Date();
    today.setHours(0, 0, 0, 0);
    const thirtyDaysAgo = new Date(today);
    thirtyDaysAgo.setDate(today.getDate() - 30);
    return [thirtyDaysAgo.getTime(), today.getTime()];
  })(),

  /**
   * 近一年
   * @returns {number[]} 近一年起止日期时间戳数组
   */
  LAST_1_YEAR: (() => {
    const today = new Date();
    today.setHours(0, 0, 0, 0);
    const oneYearAgo = new Date(today);
    oneYearAgo.setFullYear(today.getFullYear() - 1);
    return [oneYearAgo.getTime(), today.getTime()];
  })(),
};